package com.guchenbo.scala.c5

/**
 * @author guchenbo
 * @date 2022/3/21
 */
object SeqFuncDemo {

  def main(args: Array[String]): Unit = {
    val li = List(1, 2, 3, 4, 5)
    println(li.filter(_ / 2 == 0))
    println(li.map(_ + 1))
    val strings = List("hello java", "hello scala")
    println(strings.flatMap(_.split(" ")))

    println(li.groupBy(_ / 2))
    println(strings.flatMap(_.split(" ")).groupBy(_.charAt(0)))

    println(li.sum)
    println(li.reduce(_ * _))


    println(li.fold(10)(_ + _))
  }
}
